home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!usenet
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: typedef Trouble (formerly (no subject))
- Date: Mon, 15 Apr 1996 12:11:40 -0400
- Organization: Datalytics, Inc
- Message-ID: <3172753C.337C@datalytics.com>
- References: <4kgn17$5bb@mozart.wg.icl.co.uk>
- NNTP-Posting-Host: 204.62.224.71
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Adel El-Beik wrote:
- >
- > Can anyone explain why line 1 doesn't get passed MSVC++ 4.00
- > compiler. Whereas line 2 does. MSVC++ complains it cannot perform
- > the conversion.
- >
- > typedef long bar[2][2];
- > typedef const long (*const_bar)[2];
-
- This typedef declares const_bar as an array of function
- pointers, I think. The confusion, for me, is the lack of a
- parameter list and how that affects the interpretation of the
- typedef. I'm guessing that const_bar is a two-dimensional array
- of function pointers taking no parameters and returning a const
- long. In other words, it may really be this:
-
- typedef const long (*const_bar)(void)[2];
-
- It could also be a two-dimensional array of function pointers
- taking undefined parameters and returning a const long.
-
- Neither interpretation is what you appear to want below anyway.
-
- >
- > void func( const bar param ){}
- >
- >
- >
- > void main()
- > {
- > bar x;
- >
- > func( x ); // 1
- >
- > func( (const_bar)x ); // 2
-
- So why not just do this:
-
- func((const bar)x);
-
- which really shouldn't be necessary. That is, this should work:
-
- func(x);
-
- If you really want a typedef that is equivalent to const bar,
- doesn't this work?
-
- typedef const bar const_bar;
-
- The direct equivalent is, I think, this:
-
- typedef long const const_bar[2][2];
-
- > }
- >
-
- All of the above is conjecture. I don't have time to test any
- of this code. Try at your own risk.
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc. | stew@datalytics.com
-